 function shint(typed) {
  if(typed.length==0 || typed==null) {
   document.getElementById('subjhints').style.display = "none";
   return;
  }
  
  if(window.XMLHttpRequest) {
   xmlreq = new XMLHttpRequest();
  }
  else {
   xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  xmlreq.onreadystatechange = function() {
   if(xmlreq.readyState == 4 && xmlreq.status == 200) {
    document.getElementById('subjhints').style.display = "inline";
    document.getElementById('subjhints').innerHTML = xmlreq.responseText;
   }
   else {
    document.getElementById('subjhints').style.display = "none";
   }
  }
  
  typed = typed.split(", ");
  xmlreq.open("GET", "getsubjs.php?q="+typed.pop(), true);
  xmlreq.send();
 }
 
 function includeme(theitem) {
  theitem = theitem.replace(/_/g, " ");
  toappend = document.getElementById('subjdept').value;
  
  if(toappend.lastIndexOf(", ") == -1) {
   toappend = theitem + ", ";
  }
  else {
   toappend = toappend.substr(0, toappend.lastIndexOf(",")+2) + theitem + ", ";
  }
  document.getElementById('subjdept').value = toappend;
  document.getElementById('subjhints').style.display = "none";
 }